package com.smartlbs.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.smartlbs.baseframe.utils.ConfigFileUtils;
import com.smartlbs.enums.SettingEnums;
import com.smartlbs.service.ISettingService;
import com.smartlbs.util.StringUtil;

@Service("settingService")
public class SettingServiceImpl implements ISettingService{

	@Override
	public boolean setting(Integer type, String value) {
		//返回值信息
		boolean bl = false;
		
		ConfigFileUtils.PROPERTY_PATH = "configs/setting/info.properties";
		//
		String key = SettingEnums.getMemoByValue(type);
		
		//设置属性
		ConfigFileUtils.setPropertyString(key, value, null);
		
		bl = true;
		
		return bl;
	}

	@Override
	public Map<String, String> getSetting(String types) {
		//
		Map<String, String> resultMap = new HashMap<>();
		//
		ConfigFileUtils.PROPERTY_PATH = "configs/setting/info.properties";
		
		//
		for(Integer type:StringUtil.transferStr2Set(types, ",")){
			//
			String key = SettingEnums.getMemoByValue(type);
			
			//设置属性
			String property = ConfigFileUtils.getPropertyString(key);
			
			resultMap.put(key, property);
		}

		return resultMap;
	}
}